home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / handson / supercede / Knowodys / Projects / Palette2 / rgb / Form1.java < prev    next >
Encoding:
Java Source  |  1998-01-19  |  6.4 KB  |  240 lines

  1. /**
  2.  * 
  3.  * You can add code anywhere in this file - except in the areas that are
  4.  * written by the editor. You should not change the relative ordering of
  5.  * the code.
  6.  * 
  7.  * You can remove this comment block or replace it with another.
  8.  * 
  9.  * @see        
  10.  * @version    
  11.  * @author    
  12.  */
  13.  
  14.  
  15. import com.supercede.forms.*;
  16. import java.util.*;
  17. import java.net.*;
  18. import java.io.*;
  19. import java.beans.*;
  20. import java.awt.event.*;
  21. import java.awt.*;
  22.  
  23. public class Form1 extends SuperCedeFrame implements Serializable
  24. {
  25.  
  26.     public Form1() throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException
  27.     {
  28.         SuperCedeConstructor();        // Do not remove this line.
  29.     }
  30.  
  31.     public static void main(String args[])
  32.     {
  33.         // You can add code anywhere in this method.
  34.  
  35.         try
  36.         {
  37.             Form1 app = new Form1();
  38.             app.setVisible(true);
  39.         }
  40.         catch(Throwable t)
  41.         {
  42.             System.out.println("Cannot construct the form: " + t);
  43.             System.exit(1);
  44.         }
  45.     }
  46.  
  47.     public void form1WindowClosing(WindowEvent e)
  48.     {
  49.         // You can add code anywhere in this method.
  50.  
  51.         dispose();
  52.     }
  53.  
  54.     public void form1WindowClosed(WindowEvent e)
  55.     {
  56.         // You can add code anywhere in this method.
  57.  
  58.         SuperCedeWindowClosed();
  59.     }
  60.     void updateColor()
  61.       {
  62.        Color c = new Color( redScroll.getValue(),
  63.                             greenScroll.getValue(),
  64.                             blueScroll.getValue());
  65.        myCanvas.setBackground(c);
  66.       }
  67.     public void redScrollAdjustmentValueChanged(AdjustmentEvent arg0)
  68.     {
  69.         // Put event handler code here...
  70.         updateColor();
  71.     }
  72.  
  73. public void blueScrollAdjustmentValueChanged(AdjustmentEvent arg0)
  74.     {
  75.         // Put event handler code here...
  76.         updateColor();
  77.     }
  78.  
  79.     public void greenScrollAdjustmentValueChanged(AdjustmentEvent arg0)
  80.     {
  81.         // Put event handler code here...
  82.         updateColor();
  83.     }
  84.  
  85.     // SuperCede Begin 2.0 Form Members
  86.     // Do not remove the Begin and End markers.
  87.     // The editor will rewrite the contents of this section each time the form is saved.
  88.  
  89.     // References to Beans within the Form.
  90.  
  91.     Canvas myCanvas;
  92.     com.supercede.beans.stdawt.ScrollbarH redScroll;
  93.     com.supercede.beans.stdawt.ScrollbarH greenScroll;
  94.     com.supercede.beans.stdawt.ScrollbarH blueScroll;
  95.  
  96.     private final void SuperCedeConstructor() throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException
  97.     {
  98.         // Construct the actual connectors to give to our base class.
  99.  
  100.         Vector connectors = new Vector(5);
  101.         connectors.addElement(new Form1WindowClosingConnector0());
  102.         connectors.addElement(new Form1WindowClosedConnector1());
  103.         connectors.addElement(new Form1EventConnector2());
  104.         connectors.addElement(new Form1EventConnector3());
  105.         connectors.addElement(new Form1EventConnector4());
  106.  
  107.         super.initializeThis(connectors);
  108.  
  109.         // Make references to Beans within the Form.
  110.  
  111.         int i = 0;
  112.  
  113.         myCanvas = (Canvas) getComponent(i++);
  114.         redScroll = (com.supercede.beans.stdawt.ScrollbarH) getComponent(i++);
  115.         greenScroll = (com.supercede.beans.stdawt.ScrollbarH) getComponent(i++);
  116.         blueScroll = (com.supercede.beans.stdawt.ScrollbarH) getComponent(i++);
  117.     }
  118.  
  119.     private final void SuperCedeWindowClosed()
  120.     {
  121.         System.exit(0);
  122.     }
  123.  
  124.     // SuperCede End 2.0 Form Members
  125. }
  126.  
  127. // SuperCede Begin 2.0 Form Connectors
  128. // Do not remove the Begin and End markers.
  129. // The editor will rewrite the contents of this section each time the form is saved.
  130.  
  131. // Connections for this Form:
  132. //    Form1WindowClosingConnector0: from Form1.windowClosing to Form1.form1WindowClosing
  133. //    Form1WindowClosedConnector1: from Form1.windowClosed to Form1.form1WindowClosed
  134. //    Form1EventConnector2: from com.supercede.beans.stdawt.ScrollbarH.adjustmentValueChanged to Form1.redScrollAdjustmentValueChanged
  135. //    Form1EventConnector3: from com.supercede.beans.stdawt.ScrollbarH.adjustmentValueChanged to Form1.greenScrollAdjustmentValueChanged
  136. //    Form1EventConnector4: from com.supercede.beans.stdawt.ScrollbarH.adjustmentValueChanged to Form1.blueScrollAdjustmentValueChanged
  137.  
  138. final class Form1WindowClosingConnector0 extends WindowAdapter implements SuperCedeConnector
  139. {
  140.     private Form1 windowClosingTarget;
  141.  
  142.     public void setWindowClosingTarget(Form1 target)
  143.     {
  144.         windowClosingTarget = target;
  145.     }
  146.  
  147.     public void windowClosing(WindowEvent arg0)
  148.     {
  149.         windowClosingTarget.form1WindowClosing(arg0);
  150.     }
  151.  
  152.     public void setTarget(Object target)
  153.     {
  154.         setWindowClosingTarget((Form1) target);
  155.     }
  156. }
  157.  
  158. final class Form1WindowClosedConnector1 extends WindowAdapter implements SuperCedeConnector
  159. {
  160.     private Form1 windowClosedTarget;
  161.  
  162.     public void setWindowClosedTarget(Form1 target)
  163.     {
  164.         windowClosedTarget = target;
  165.     }
  166.  
  167.     public void windowClosed(WindowEvent arg0)
  168.     {
  169.         windowClosedTarget.form1WindowClosed(arg0);
  170.     }
  171.  
  172.     public void setTarget(Object target)
  173.     {
  174.         setWindowClosedTarget((Form1) target);
  175.     }
  176. }
  177.  
  178. final class Form1EventConnector2 implements SuperCedeConnector, java.awt.event.AdjustmentListener
  179. {
  180.     private Form1 adjustmentValueChangedTarget;
  181.  
  182.     public void setAdjustmentValueChangedTarget(Form1 target)
  183.     {
  184.         adjustmentValueChangedTarget = target;
  185.     }
  186.  
  187.     public void adjustmentValueChanged(AdjustmentEvent arg0)
  188.     {
  189.         adjustmentValueChangedTarget.redScrollAdjustmentValueChanged(arg0);
  190.     }
  191.  
  192.     public void setTarget(Object target)
  193.     {
  194.         setAdjustmentValueChangedTarget((Form1) target);
  195.     }
  196. }
  197.  
  198. final class Form1EventConnector3 implements SuperCedeConnector, java.awt.event.AdjustmentListener
  199. {
  200.     private Form1 adjustmentValueChangedTarget;
  201.  
  202.     public void setAdjustmentValueChangedTarget(Form1 target)
  203.     {
  204.         adjustmentValueChangedTarget = target;
  205.     }
  206.  
  207.     public void adjustmentValueChanged(AdjustmentEvent arg0)
  208.     {
  209.         adjustmentValueChangedTarget.greenScrollAdjustmentValueChanged(arg0);
  210.     }
  211.  
  212.     public void setTarget(Object target)
  213.     {
  214.         setAdjustmentValueChangedTarget((Form1) target);
  215.     }
  216. }
  217.  
  218. final class Form1EventConnector4 implements SuperCedeConnector, java.awt.event.AdjustmentListener
  219. {
  220.     private Form1 adjustmentValueChangedTarget;
  221.  
  222.     public void setAdjustmentValueChangedTarget(Form1 target)
  223.     {
  224.         adjustmentValueChangedTarget = target;
  225.     }
  226.  
  227.     public void adjustmentValueChanged(AdjustmentEvent arg0)
  228.     {
  229.         adjustmentValueChangedTarget.blueScrollAdjustmentValueChanged(arg0);
  230.     }
  231.  
  232.     public void setTarget(Object target)
  233.     {
  234.         setAdjustmentValueChangedTarget((Form1) target);
  235.     }
  236. }
  237.  
  238. // The following line must be the last line in the file.
  239. // SuperCede End 2.0 Form Connectors
  240.